<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<jsp:include page="/common/meta.jsp"></jsp:include>
<title>Home Page</title>
<script type="text/javascript">
function selfun(id){
	$(id).css('border-style','inset');
}
function refun(id){
	$(id).css('border-style','none');
}
function rckey(path){
	alert(path);
	$('#delF').click(function(){
		window.location='${ctx}/app/delf?path='+path;
	});
	
	
}
function rightbutton(e){    
	if (!window.event){    
	if (e.which == 2 || e.which == 3){    
		var mousep=mousePosition(e);
		$('#rightKey').css('left',mousep.x);
		$('#rightKey').css('top',mousep.y);
		$('#rightKey').show(); 
	}else{
		var mousep=mousePosition(e);
		var rightk=$('#rightKey').position();
		if(!(mousep.x>rightk.left&&mousep.x<rightk.left+$('#rightKey').width()&& mousep.y>rightk.top&& mousep.y<rightk.top+$('#rightKey').height())){
			$('#delF').unbind( "click" );	
		$('#rightKey').hide(); 
		}
	}
	}    
	else {
		if (event.button == 2 || event.button == 3){    
		var mousep=mousePosition(event);
		$('#rightKey').css('left',mousep.x);
		$('#rightKey').css('top',mousep.y);
		$('#rightKey').show();
	}else{
		var mousep=mousePosition(event);
		var rightk=$('#rightKey').position();
		if(!(mousep.x>rightk.left&&mousep.x<rightk.left+$('#rightKey').width()&& mousep.y>rightk.top&& mousep.y<rightk.top+$('#rightKey').height())){
			$('#delF').unbind( "click" );					
		$('#rightKey').hide(); 
		} 
	}
	}    
	}    

	document.onmousedown = rightbutton;

</script>
</head>
<body>
<fieldset class="mainbody" >
<table width="100%">
<c:forEach begin="0" end="${fn:length(fileList)/6}" varStatus="i">
	<tr>
		<c:forEach items="${fileList }" var="pfile" begin="${(i.count-1)*6}" end="${i.count*6}">
		
		
			<td width="16%">
			<c:choose>
				<c:when test="${pfile.fileTyp eq 'PDF'}">
					<img src="${ctx }/images/file/file.jpg" onmousedown="if(event==null){event=window.event;} if(event.button==2){rckey('${pfile.filePath }');}" ondblclick="window.location='${ctx}${pfile.fileUrl }';" />
				</c:when>
				<c:when test="${pfile.fileTyp eq 'ZIP'}">
				<img src="${ctx }/images/file/file.jpg" onmousedown="if(event==null){event=window.event;} if(event.button==2){rckey('${pfile.filePath }');}" ondblclick="window.location='${ctx}${pfile.fileUrl }';"/>
				</c:when>
				<c:when test="${pfile.fileTyp eq 'DOC'}">
				<img src="${ctx }/images/file/file.jpg" onmousedown="if(event==null){event=window.event;} if(event.button==2){rckey('${pfile.filePath }');}" ondblclick="window.location='${ctx}${pfile.fileUrl }';"/>
				</c:when>
				<c:when test="${pfile.fileTyp eq 'EXCEL'}">
				<img src="${ctx }/images/file/file.jpg" onmousedown="if(event==null){event=window.event;} if(event.button==2){rckey('${pfile.filePath }');}" ondblclick="window.location='${ctx}${pfile.fileUrl }';"/>
				</c:when>
				<c:when test="${pfile.fileTyp eq 'TXT'}">
				<img src="${ctx }/images/file/file.jpg" onmousedown="if(event==null){event=window.event;} if(event.button==2){rckey('${pfile.filePath }');}" ondblclick="window.location='${ctx}${pfile.fileUrl }';"/>
				</c:when>
				<c:otherwise>
				<img src="${ctx }/images/file/file.jpg" onmousedown="if(event==null){event=window.event;} if(event.button==2){rckey('${pfile.filePath }');}" ondblclick="window.location='${ctx}${pfile.fileUrl }';"/>
				</c:otherwise>
			</c:choose>
			</td>
		
		</c:forEach>
	</tr>

</c:forEach>
</table>
	<div id="rightKey" style='display: none;position: absolute ;cursor: pointer;background-color: #C0C0C0;border-style: outset;'>
		<table width="150px">
			<tr>
			<td id="createF"  onclick="window.location='${ctx}/app/precreatef?path=${path }'" onmouseover="selfun('#createF');" onmouseout="refun('#createF');">&nbsp;&nbsp;新建文件夹</td>
			</tr>
			<tr>
			<td id="uploadF" onclick="window.location='${ctx}/app/preuploadf?path=${path }'" onmouseover="selfun('#uploadF');" onmouseout="refun('#uploadF');">&nbsp;&nbsp;上传文件</td>
			</tr>
			<tr>
			<td  id="delF" onmouseover="selfun('#delF');" onmouseout="refun('#delF');">&nbsp;&nbsp;删除</td>
			</tr>
		</table>
	</div>
	</fieldset>
</body>
</html>